/**
 * @file utils.c
 * @brief 
 * @author henry.cai (henry.cai@queclink.com)
 * @version 1.0
 * @date 2024-09-09
 * 
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-09-09 <td>1.0     <td>henry.cai     <td>内容
 * </table>
 */
#include "utils.h"
#include <stdio.h>


/**
 * @description: int32_t转化为大端copy到buf里，返回拷贝字符的个数
 * @param {unsigned char} *buf
 * @param {int32_t} num
 * @return {0拷贝失败，4拷贝成功}
 * @Date: 2023-09-06 10:01:13
 * @modification:
 */
int32_t bigending2buf(unsigned char *buf, int32_t num)
{
    int32_t i = 0;

    if (buf == NULL)
    {
        // log_e("buf err!");
        return 0;
    }
    
    buf[i++] = (num >> 24) & 0xff;
    buf[i++] = (num >> 16) & 0xff;
    buf[i++] = (num >> 8) & 0xff;
    buf[i++] = num & 0xff;

    return i;
}
